<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            margin: 0 auto;
            width: 480px;
            height: 480px;
            background: url('./erik_ce204002.jpg') no-repeat;
            background-position: 0 -7680px;
        }
    </style>
</head>

<body>
    <div id="photo"></div>
    <script>
        var div = document.getElementById('photo');
        var m = 0;
        var direction = true;
        setInterval(function() {
            console.log(m)
            if (direction) {
                if (m <= -7200) {
                    direction = false;
                }
                m -= 480
                div.style.backgroundPositionY = m + 'px';
            } else {
                if (m > 0) {
                    direction = true;
                }
                m += 480
                div.style.backgroundPositionY = m + 'px';
            }
        }, 100);
    </script>
</body>

</html>